﻿<%@ Page Language="C#" MasterPageFile="~/admin.master" AutoEventWireup="true" Inherits="MediaMonitor.Admin.Data_Mgmt_Sector"
    Theme="default" Title="Data Management - Sectors & Sub Sectors & Categories"
    CodeBehind="data-mgmt-sector.aspx.cs" %>


<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Head" runat="Server">
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

        <script src="../rad-scripts/rad.js" type="text/javascript"></script>

    </telerik:RadCodeBlock>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Body" runat="Server">

    <div>
        Click the
        <img src="../App_Themes/default/cssimg/exapand.png" style="display: inline;" />
        link at the left side of records to expand the data.
        <br />
    </div>
    <div style="padding: 5px; width: 90%;">
    <telerik:RadAjaxPanel ID="radPanel" runat="server" RestoreOriginalRenderDelegate="false">
        
    
        <telerik:RadGrid ID="radGrid" runat="server" AllowFilteringByColumn="True" AllowPaging="True"
            AllowSorting="True" GridLines="None" Skin="Hay" OnNeedDataSource="radGrid_NeedDataSource"
            Width="100%" AutoGenerateColumns="False" GroupingSettings-CaseSensitive="false"
            PageSize="50" OnDeleteCommand="radGrid_DeleteCommand">
                 
            <MasterTableView DataKeyNames="SectorCode" ExpandCollapseColumn-Groupable="true" ExpandCollapseColumn-GroupByExpression="SectorCode" GroupLoadMode="Client">
                <Columns>
                    <telerik:GridButtonColumn Text="Delete" ButtonType="LinkButton" ConfirmText="Are you sure to delete this record? All it's sub sectors would also be deleted"  ConfirmTitle="Delete Confirmation" CommandName="Delete" />
                    <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="SectorCode" HeaderText="Sector Code" Groupable="true" GroupByExpression="SectorCode" />
                    <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="SectorName" HeaderText="Sector" />
                    <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="LastModifiedDate" HeaderText="Last Modified"
                        HtmlEncode="false" DataFormatString="{0:d}" />
                </Columns>
                
                <DetailTables>
                    <telerik:GridTableView  AutoGenerateColumns="false" Caption="" AllowSorting="true"
                        PageSize="10" DataSourceID="sqlDSSubSec" DataKeyNames="SubSectorCode" ExpandCollapseColumn-Groupable="true" ExpandCollapseColumn-GroupByExpression="SubSectorCode" GroupLoadMode="Client">
                        <ParentTableRelation>
                            <telerik:GridRelationFields MasterKeyField="SectorCode" DetailKeyField="SectorCode" />
                        </ParentTableRelation>
                        <ItemStyle CssClass="Level2AltItem" />
                        <AlternatingItemStyle CssClass="Level2AltItem" />
                        <FilterItemStyle BackColor="#898989" ForeColor="White" />
                        
                        <Columns>
                            <telerik:GridButtonColumn Text="Delete" ButtonType="LinkButton" ConfirmText="Are you sure to delete this record?" ConfirmTitle="Delete Confirmation" CommandName="Delete" />
                            <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="SubSectorCode" HeaderText="SubSectorCode" />
                            <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="SubSectorName" HeaderText="SubSector" />
                            <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="DateModified" HeaderText="Last Modified" HtmlEncode="false" DataFormatString="{0:d}" />
                        </Columns>
                        
                        <DetailTables>
                            <telerik:GridTableView DataKeyNames="CategoryCode" AutoGenerateColumns="false" Caption=""
                                AllowSorting="true" PageSize="10" DataSourceID="sqlDSCat">
                                <ParentTableRelation>
                                    <telerik:GridRelationFields MasterKeyField="SubSectorCode" DetailKeyField="SubSectorCode" />
                                </ParentTableRelation>
                                <ItemStyle CssClass="Level3AltItem" />
                                <AlternatingItemStyle CssClass="Level3AltItem" />
                                <FilterItemStyle BackColor="#898989" ForeColor="White" />
                                <Columns>
                                    <telerik:GridButtonColumn Text="Delete" ButtonType="LinkButton" ConfirmText="Are you sure to delete this record?" ConfirmTitle="Delete Confirmation" CommandName="Delete" />
                                    <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="CategoryCode" HeaderText="Category Code" />
                                    <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="CategoryName" HeaderText="Category" />
                                    <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="DateModified" HeaderText="Last Modified" HtmlEncode="false"
                                        DataFormatString="{0:d}" />
                                </Columns>
                            </telerik:GridTableView>
                        </DetailTables>
                        
                    </telerik:GridTableView>
                </DetailTables>
            </MasterTableView>
            <ClientSettings>
                <Scrolling AllowScroll="false" />
                <ClientEvents OnFilterMenuShowing="filterMenuShowing" />
            </ClientSettings>
            <FilterMenu OnClientShowing="MenuShowing" />
        </telerik:RadGrid>
        
    </telerik:RadAjaxPanel>
    </div>
    
    <asp:SqlDataSource ID="sqlDSSubSec" runat="server" ConnectionString="<%$ ConnectionStrings:DBAdex %>"
        SelectCommand="SELECT * FROM SubSector WHERE SectorCode = @SectorCode ORDER BY SubSectorName">
         <SelectParameters>
            <asp:Parameter Name="SectorCode" DefaultValue="0" Type="Int32" />
        </SelectParameters> 
    </asp:SqlDataSource>
    
    <asp:SqlDataSource ID="sqlDSCat" runat="server" ConnectionString="<%$ ConnectionStrings:DBAdex %>"
        SelectCommand="SELECT * FROM Category WHERE SubSectorCode = @SubSectorCode ORDER BY CategoryName">
        <SelectParameters>
            <asp:Parameter Name="SubSectorCode" DefaultValue="0" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
   
</asp:Content>
